//===============================================================================
// Microsoft patterns & practices
// Smart Client Software Factory
//===============================================================================
// Copyright (C) Microsoft Corporation.  All rights reserved.
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY
// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT
// LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
// FITNESS FOR A PARTICULAR PURPOSE.
//===============================================================================
// The example companies, organizations, products, domain names,
// e-mail addresses, logos, people, places, and events depicted
// herein are fictitious.  No association with any real company,
// organization, product, domain name, email address, logo, person,
// places, or events is intended or should be inferred.
//===============================================================================

//----------------------------------------------------------------------------------------
// patterns & practices - Smart Client Software Factory - Guidance Package
//
// This file was generated by the "Add View" recipe.
//
// This class is the concrete implementation of a View in the Model-View-Presenter 
// pattern. Communication between the Presenter and this class is acheived through 
// an interface to facilitate separation and testability.
// Note that the Presenter generated by the same recipe, will automatically be created
// by CAB through [CreateNew] and bidirectional references will be added.
//
// For more information see:
// ms-help://MS.VSCC.v80/MS.VSIPCC.v80/ms.scsf.2006jun/SCSF/html/03-030-Model%20View%20Presenter%20%20MVP%20.htm
//
// Latest version of this Guidance Package: http://go.microsoft.com/fwlink/?LinkId=62182
//----------------------------------------------------------------------------------------

using System.Windows.Forms;
using GlobalBank.CreditCardAccounts.Module.Properties;
using Microsoft.Practices.CompositeUI.SmartParts;
using Microsoft.Practices.ObjectBuilder;
using System.Globalization;

namespace GlobalBank.CreditCardAccounts.Module
{
	[SmartPart]
	public partial class CreditCardAccountView : UserControl, ICreditCardAccountView, ISmartPartInfoProvider
	{
		public CreditCardAccountView()
		{
			InitializeComponent();
		}

		/// <summary>
		/// Sets the presenter. The dependency injection system will automatically
		/// create a new presenter for you.
		/// </summary>
		[CreateNew]
		public CreditCardAccountViewPresenter Presenter
		{
			set
			{
				_presenter = value;
				_presenter.View = this;
			}
		}

		private void buttonCancel_Click(object sender, System.EventArgs e)
		{
			_presenter.OnCloseView();
			Dispose();
		}

		public ISmartPartInfo GetSmartPartInfo(System.Type smartPartInfoType)
		{
			string title =
				string.Format(CultureInfo.CurrentUICulture, Resources.CreditCardAccountViewLabel,
				              _presenter.GetCreditCardLast4Digits());
			return new SmartPartInfo(title, string.Empty);
		}
	}
}
